Add support for page-breaks to be inserted before elements that would otherwise intersect them#118
Add support for page-breaks to be inserted before elements that would otherwise intersect them#118jbryan76 wants to merge 1 commit intoeKoopmans:developfrom
Conversation
… otherwise intersect them. Any element with class 'html2pdf__avoid-page-break' that intersects a page-break will instead be pushed to the next page.
|
This is great! Thank you. It sounds like it'd resolve this issue: https://github.com/ebdrup/html2pdf.it/issues/72 |
|
Yes I believe so. Sounds like we could put up for debate best css class name to use to enable it, but we have a project with critical need for this functionality so are using a patched local copy until something official is available. |
|
I see my reply above was from another project. Sorry for the confusion. |
|
Regarding the naming, it might be a good to use 'page-break-before', 'page-break-after' and 'page-break-inside' since those are standards [ https://css-tricks.com/almanac/properties/p/page-break/ ]. Could those be used in addition to 'html2pdf__avoid-page-break' and 'html2pdf__page-break' so older projects don't break? |
|
Those sound better, in particular if they are a standard. They imply some additional patching though since this PR essentially is only for page-break-inside. Another issue is whether to keep the css class approach or try to mine it from the element style itself instead. Changing html2pdf__avoid-page-break to eg html2pdf__page-break-inside is trivial on my end - it's early enough in the project to have minimal impact. I will probably do that proactively. If I have time I will update, but ultimately it may be up to eKoopmans who has been silent so far. |
|
... Hello! Sorry for the long silence. Thanks @jbryan76, this is a great addition. And @campsoftware I appreciate the info about the CSS standards, that gives a clear direction on how to go forward. Though I'm not sure how to implement There are also 4 different pagebreak PRs now, so I'm looking into combining all 4. Do either of you see any issues with adjusting an element's margin (as in #138) instead of injecting resized I'll probably keep the class-based |
|
@eKoopmans, do you have a timeline of when you'd have time to combine the PRs and release the page-break changes? |
|
@ZabbyCapurin I have a draft mostly finished, I'll submit it as a PR for testing before merging anything in. |
|
Hey @ZabbyCapurin @jbryan76 @campsoftware, I've put up a new page-break PR #153, take a look if you have a chance. I haven't had time yet to do any testing with it, so please let me know if there's any issues. |
|
Resolved by #153, closing! |
Any element with class 'html2pdf__avoid-page-break' that intersects a page-break will instead be pushed to the next page by inserting a shim div before it.
Elements with the class that span more than a full page are ignored.
Confirmed working on latest source for documents with multiple pages.